/**
 * 登录
 * @param req
 * @param resp
 */
let login = (req,resp) => {
    let query = req.query;
    let name = query.name;
    let pwd = query.pwd;

    console.log(`当前全局名字:${global.cname},全局密码:${global.cpwd}`)
    if (name === global.cname && pwd === global.cpwd){
        resp.send("登陆成功")
    }else {
        throw new Error('用户名或密码错误')
    }
}
/**
 * 注册
 * @param req
 * @param resp
 */
let regist =(req,resp) => {
    let body = req.body;
    let name = body.name;
    let pwd =body.pwd;
    global.cname =name;
    global.cpwd = pwd;
    resp.send('注册成功')
}
let getUserInfo = (req,resp) =>{
    let header = req.headers;
    let token = header.token;
    let cookies=req.cookies;
    let zupeng=cookies.zupeng;
    resp.cookie('zuqiang',new Date().getTime())
    resp.send({
        name:'zupeng',
        class:'123',
        token:token,
        zupeng
    })
}
module.exports = {login,regist,getUserInfo}
